package com.maserb.monitor.repository.JwQuestion;

import com.maserb.monitor.entity.jwQuestion.JwQuestionUserEntity;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface JwQuestionUserRepository extends JpaSpecificationExecutor<JwQuestionUserEntity>
        , PagingAndSortingRepository<JwQuestionUserEntity, String> {
    List<JwQuestionUserEntity> findByUserName(String userName);

    List<JwQuestionUserEntity> findAllByQuestionIdOrderByCreateTimeAsc(String questionId);

    List<JwQuestionUserEntity> findAllByQuestionIdOrderByCreateTimeAsc(Pageable pageable,String questionId);

    List<JwQuestionUserEntity> findByQuestionIdAndUserName(String questionId,String userName);

    @Query(value = "select count(*) from JwQuestionUserEntity where questionId=?1 ")
    Long selectCountByQuestionId(String questionId);

}